package swings.mycomponent.progressmonitor;

import java.awt.BorderLayout;
import java.awt.EventQueue;
import java.awt.GraphicsEnvironment;
import java.awt.Point;

import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.border.EmptyBorder;

/**
 * @Title: SwingWorkerExampleJFrame.java
 * @Description: TODO(演示 SwingWorkerExampleJPanel 的用法。)
 * @author H819
 * @date 2011-2-24
 * @version V1.0
 */

public class SwingWorkerExampleJFrame extends JFrame {

	private JPanel contentPane;

	/**
	 * Launch the application.
	 */
	public static void main(String[] args) {
		EventQueue.invokeLater(new Runnable() {
			public void run() {
				try {
					SwingWorkerExampleJFrame frame = new SwingWorkerExampleJFrame();
					frame.setVisible(true);
				} catch (Exception e) {
					e.printStackTrace();
				}
			}
		});
	}

	/**
	 * Create the frame.
	 */
	public SwingWorkerExampleJFrame() {

		setResizable(false);
		setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

		// 窗口居中
		Point center = GraphicsEnvironment.getLocalGraphicsEnvironment()
				.getCenterPoint();
		int windowWidth = 450;
		int windowHeight = 300;

		setBounds(center.x - windowWidth / 2, center.y - windowHeight / 2,
				windowWidth, windowHeight);

		contentPane = new JPanel();
		contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
		contentPane.setLayout(new BorderLayout(0, 0));
		setContentPane(contentPane);

		// 引入定制好的 Jpanel
		JPanel panel = new SwingWorkerExampleJPanel();
		contentPane.add(panel, BorderLayout.CENTER);

	}

}
